package cn.ncupyh.comptest;
//按顺序打印数字
public class PrintNumInOrder {
    public static void main(String[] args) {
        printNum(123);
        int sum =0;
//        for (int i = 1; i <= 10; i++) {
//            sum += i;
//        }
//        System.out.println(sum);
        int sum1 = sum(10);
        System.out.println(sum1);
    }

    private static int sum(int i) {
        if(i == 1){
            return 1;
        }
        return i+sum(i-1);
    }


    private static void printNum(int i) {
        if(i <= 9){
            System.out.println(i);
        }else{
            printNum(i/10);
            System.out.println(i%10);
        }
    }
}
